﻿Public Class StatusWindow

    'Public Shared UseLog As Boolean
    'Public Shared log As Logger

    Private UseLog As Boolean = False
    Public Property DebugToLog() As Boolean
        Get
            Return UseLog
        End Get
        Set(ByVal value As Boolean)
            UseLog = value
        End Set
    End Property

    Private log As Logger
    Public Property LogToUse() As Logger
        Get
            Return Log
        End Get
        Set(ByVal value As Logger)
            log = value
        End Set
    End Property

    Private Sub StatusWindow_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.DoubleBuffered = True
        Me.Size = My.Settings.DebugSize
        Me.Location = My.Settings.DebugPos
        Me.WindowState = My.Settings.DebugWinState
    End Sub

    Public Sub echo(MainText As String, Optional ErrorFlag As Boolean = False, Optional Heading As String = "")
        Dim Out As String = ""
        'If _timestamp = True Then Out += DateTime.Now.ToString("HH:mm:ss") & " | "
        If ErrorFlag = True Then Out += "ERROR: "
        If Heading <> "" Then Out += Heading.ToUpper & ": "
        Out += MainText & vbCr
        'DBOut.SelectionColor = _textcolor
        DBOut.AppendText(Out)
        'DBOut.Refresh()

        If UseLog = True Then
            If ErrorFlag = False Then
                If Heading <> "" Then
                    log.echo("DEBUG: " & MainText)
                Else
                    log.echo("DEBUG: " & MainText, Heading)
                End If
            Else
                If Heading <> "" Then
                    log.err("DEBUG: " & MainText)
                Else
                    log.err("DEBUG: " & MainText, Heading)
                End If
            End If

        End If

        DBOut.SelectionStart = DBOut.Text.Length
        DBOut.ScrollToCaret()

    End Sub

End Class